package com.ihr360.payroll.dao;

import com.ihr360.payroll.model.dto.salary.plan.SalaryPlanStaff;
import com.ihr360.payroll.model.dto.salary.plan.idclass.SalaryPlanStaffId;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import javax.transaction.Transactional;
import java.util.List;

@RepositoryRestResource
public interface SalaryPlanStaffRepository extends PagingAndSortingRepository<SalaryPlanStaff, SalaryPlanStaffId> {
    List<SalaryPlanStaff> findBySalaryPlanIdAndEnabled(@Param("salaryPlanId") Long salaryPlanId, @Param("enabled") Boolean enabled);

    List<SalaryPlanStaff> findBySalaryPlanId(@Param("salaryPlanId") Long salaryPlanId);

    void deleteBySalaryPlanIdAndStaffIdIn(Long planId, List<String> staffIdList);

    List<SalaryPlanStaff> findAllBySalaryPlanIdAndStaffIdIn(Long planId, List<String> staffIdList);

    List<SalaryPlanStaff> findBySalaryPlanIdAndStaffStateIn(Long salaryPlanId, List<Integer> staffStateList);

    List<SalaryPlanStaff> findBySalaryPlanIdAndEnabledAndStaffStateIn(Long salaryPlanId, boolean enabled,
                                                                      List<Integer> staffStateList);

    List<SalaryPlanStaff> findBySalaryPlanIdInAndEnabledAndStaffStateIn(List<Long> salaryPlanIds, boolean enabled,
                                                                        List<Integer> staffStateList);

    List<SalaryPlanStaff> findAllBySalaryPlanIdAndStaffStateIn(Long planId, List<Integer> staffStateList);

    List<SalaryPlanStaff> findAllByStaffIdIn(List<String> staffStateList);

    int countBySalaryPlanIdAndEnabledAndStaffStateIn(Long salaryPlanId, boolean enabled,
                                                                      List<Integer> staffStateList);
    @Transactional
    long deleteBySalaryPlanId(Long salaryPlanId);

}